FROM golang:alpine AS builder


ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct

WORKDIR /build

RUN go mod init demo
RUN go mod tidy

COPY . .
COPY ./etc /app/etc
RUN go build -ldflags="-s -w" -o /app/demo .


FROM scratch

WORKDIR /app
COPY --from=builder /app/demo /app/demo
COPY --from=builder /app/etc /app/etc

CMD ["./demo", "-f", "etc/demo-api.yaml"]
